﻿using DXApplicationTangche.service;
using DXApplicationTangche.UC.面料审核.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.面料审核
{
    public partial class Form受托加工方一览 : DevExpress.XtraEditors.XtraForm
    {
        private List<ShopRightQueryFacadeDTO> shopRightQueryFacadeDTOs = new List<ShopRightQueryFacadeDTO>();
        public Form受托加工方一览()
        {
            InitializeComponent();
            this.shopRightQueryFacadeDTOs = UserPrivilegesService.getShopRightQueryFacadeByOrgId("shunqiu").shopRightQueryFacadeDTOList;
            this.gridControl受托加工方一览.DataSource = this.shopRightQueryFacadeDTOs;
            this.gridView受托加工方一览.ExpandAllGroups();
        }

        private void 制定生产计划ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShopRightQueryFacadeDTO shopRightQueryFacadeDTO传参 = new ShopRightQueryFacadeDTO();
            ShopInfoDTO shopInfoDTO = new ShopInfoDTO();
            String shopId = this.gridView受托加工方一览.GetRowCellValue(this.gridView受托加工方一览.FocusedRowHandle, "shopId").ToString();
            foreach(ShopRightQueryFacadeDTO shopRightQueryFacadeDTO in this.shopRightQueryFacadeDTOs)
            {
                if (shopId.Equals(shopRightQueryFacadeDTO.shopId))
                {
                    shopInfoDTO = new ShopInfoDTO(shopRightQueryFacadeDTO);
                    shopRightQueryFacadeDTO传参 = shopRightQueryFacadeDTO;
                }
            }
            //获取shopId，传参用
            List<String> shopIds = new List<string>();
            shopIds.Add(shopInfoDTO.shopId);
            //判断返回值是否有值
            List<WIPBatchWIthMBomDTO> wIPBatchWIthMBomDTOs = 面料审核Service.getFabricBOMConsumption(shopIds);
            if (wIPBatchWIthMBomDTOs.Count > 0)
            {
                new Form面料待处理(shopInfoDTO, shopRightQueryFacadeDTO传参).ShowDialog();
            }
            else
            {
                MessageBox.Show("无待处理面料");
                return;
            }
        }
    }
}
